package setting

import (
	"github.com/spf13/viper"
	"go-caipu/pkg/plugins/log"
)

type PluginCfg struct {
	log                  log.Logger
	DevMode              bool
	PluginsPath          string
	PluginSettings       map[string]map[string]string
	PluginsAllowUnsigned []string
	CaiPuComURL          string
	PluginSensitives     []string
}

func (cfg *Cfg) readPluginSettings(viper *viper.Viper) error {
	cfgPlugin := viper.Sub("plugin")
	cfg.PluginCfg = PluginCfg{
		DevMode:          cfg.Application.Mode == "development",
		PluginsPath:      cfgPlugin.GetString("PluginSettings"),
		CaiPuComURL:      cfgPlugin.GetString("caiPuComUrl"),
		PluginSensitives: cfgPlugin.GetStringSlice("pluginSensitives"),
	}

	return nil
}
